/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.awt.event.MouseListener;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import logic.MainWindowLogic;

/**
 *
 * Author: 2Dai
 * Colaborated: Jorge Garrido Oval
 * Colaborated: José Iván Palmer García
 */
public class MainWindow extends javax.swing.JFrame {
    public static MainWindow window;
    private final JButton minimizar = new JButton(new ImageIcon(getClass().getResource("/img/16x16/actions/ledyellow.png")));
    private final JButton salir = new JButton(new ImageIcon(getClass().getResource("/img/16x16/actions/ledred.png")));
    /** Creates new form MainWindow */
    public MainWindow() {
        initComponents();

    }

    public MainWindow(MainWindowLogic logic) {
        this();
        //LOCALES
        JMIlocales.addActionListener(logic);
        JBlocales.addActionListener(logic);
        //CLASIFICACIÓN EQUIPOS
        JMIclasequipos.addActionListener(logic);
        //JUGADORES
        JMIjugadores.addActionListener(logic);
        JBjugadores.addActionListener(logic);
        //CLUBS
        JMIclubs.addActionListener(logic);
        JBclubs.addActionListener(logic);
        //REPRESENTANTES CLUB
        JMIRepresentantesClub.addActionListener(logic);
        //ARBITROS
        JMIarbitros.addActionListener(logic);
        JBarbitros.addActionListener(logic);
        //RANKINGS
        JMIranking.addActionListener(logic);
        JBranking.addActionListener(logic);
        //CALENDARIO EVENTOS
        JMIcalendario.addActionListener(logic);
        JBcalendario.addActionListener(logic);
        //EQUIPOS
        JMIequipos.addActionListener(logic);
        //LOGGER
        JMIlog.addActionListener(logic);
        //SALIR
        JMIsalir.addActionListener(logic);
        //PONEMOS LOS MOUSELISTENER
        this.crearMenusAdicionales(logic);
        //ACERCA_DE
        JMIacercaDe.addActionListener(logic);
        //ACTA
        JMIacta.addActionListener(logic);
        //CONFIG
        JMIconfig.addActionListener(logic);
    }

    private void crearMenusAdicionales(MouseListener logic) {
        // Menu para salir
        salir.setBorderPainted(false);
        salir.setContentAreaFilled(false);
        salir.addMouseListener(logic);

        // Menu para minimizar
        minimizar.setBorderPainted(false);
        minimizar.setContentAreaFilled(false);
        minimizar.addMouseListener(logic);
        minimizar.setFocusable(false);
        salir.setFocusable(false);
        this.jMenuBar1.add(Box.createHorizontalGlue());
        this.jMenuBar1.add(minimizar);
        this.jMenuBar1.add(salir);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        JDPescritorio = new javax.swing.JDesktopPane();
        jToolBar1 = new javax.swing.JToolBar();
        JBlocales = new javax.swing.JButton();
        JBjugadores = new javax.swing.JButton();
        JBclubs = new javax.swing.JButton();
        JBarbitros = new javax.swing.JButton();
        JBranking = new javax.swing.JButton();
        JBcalendario = new javax.swing.JButton();
        JPcargando = new javax.swing.JPanel();
        JPBcargando = new javax.swing.JProgressBar();
        JLestado = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        JMmenu1 = new javax.swing.JMenu();
        JMIlocales = new javax.swing.JMenuItem();
        JMIjugadores = new javax.swing.JMenuItem();
        JMIclubs = new javax.swing.JMenuItem();
        JMIarbitros = new javax.swing.JMenuItem();
        JMIequipos = new javax.swing.JMenuItem();
        JMIacta = new javax.swing.JMenuItem();
        JMIRepresentantesClub = new javax.swing.JMenuItem();
        JMmenu2 = new javax.swing.JMenu();
        JMIranking = new javax.swing.JMenuItem();
        JMIclasequipos = new javax.swing.JMenuItem();
        JMIcalendario = new javax.swing.JMenuItem();
        JMopciones = new javax.swing.JMenu();
        JMIlog = new javax.swing.JMenuItem();
        JMIacercaDe = new javax.swing.JMenuItem();
        JMIconfig = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        JMIsalir = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Ping Pong Manager");
        setResizable(false);
        setUndecorated(true);

        JDPescritorio.setBackground(new java.awt.Color(235, 233, 237));
        JDPescritorio.setOpaque(false);
        getContentPane().add(JDPescritorio, java.awt.BorderLayout.CENTER);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        JBlocales.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/48x48/actions/gohome.png"))); // NOI18N
        JBlocales.setText("Locales");
        JBlocales.setFocusable(false);
        JBlocales.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JBlocales.setMaximumSize(new java.awt.Dimension(75, 70));
        JBlocales.setMinimumSize(new java.awt.Dimension(75, 70));
        JBlocales.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(JBlocales);

        JBjugadores.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/48x48/apps/kuser.png"))); // NOI18N
        JBjugadores.setText("Jugadores");
        JBjugadores.setFocusable(false);
        JBjugadores.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JBjugadores.setMaximumSize(new java.awt.Dimension(75, 70));
        JBjugadores.setMinimumSize(new java.awt.Dimension(75, 70));
        JBjugadores.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(JBjugadores);

        JBclubs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/48x48/filesystems/services.png"))); // NOI18N
        JBclubs.setText("Clubs");
        JBclubs.setFocusable(false);
        JBclubs.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JBclubs.setMaximumSize(new java.awt.Dimension(75, 70));
        JBclubs.setMinimumSize(new java.awt.Dimension(75, 70));
        JBclubs.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(JBclubs);

        JBarbitros.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/48x48/apps/edu_languages.png"))); // NOI18N
        JBarbitros.setText("Arbitros");
        JBarbitros.setFocusable(false);
        JBarbitros.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JBarbitros.setMaximumSize(new java.awt.Dimension(75, 70));
        JBarbitros.setMinimumSize(new java.awt.Dimension(75, 70));
        JBarbitros.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(JBarbitros);

        JBranking.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/48x48/apps/korganizer.png"))); // NOI18N
        JBranking.setText("Ranking");
        JBranking.setFocusable(false);
        JBranking.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JBranking.setMaximumSize(new java.awt.Dimension(75, 70));
        JBranking.setMinimumSize(new java.awt.Dimension(75, 70));
        JBranking.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(JBranking);

        JBcalendario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/48x48/apps/date.png"))); // NOI18N
        JBcalendario.setText("Eventos");
        JBcalendario.setActionCommand("Calendario");
        JBcalendario.setFocusable(false);
        JBcalendario.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        JBcalendario.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(JBcalendario);

        getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START);

        JPcargando.setPreferredSize(new java.awt.Dimension(453, 20));

        JLestado.setText("Estado:");

        javax.swing.GroupLayout JPcargandoLayout = new javax.swing.GroupLayout(JPcargando);
        JPcargando.setLayout(JPcargandoLayout);
        JPcargandoLayout.setHorizontalGroup(
            JPcargandoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, JPcargandoLayout.createSequentialGroup()
                .addContainerGap(380, Short.MAX_VALUE)
                .addComponent(JLestado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(JPBcargando, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        JPcargandoLayout.setVerticalGroup(
            JPcargandoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JPcargandoLayout.createSequentialGroup()
                .addGroup(JPcargandoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(JLestado, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(JPBcargando, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        getContentPane().add(JPcargando, java.awt.BorderLayout.PAGE_END);

        JMmenu1.setText("Mantenimientos");

        JMIlocales.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK));
        JMIlocales.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/actions/gohome.png"))); // NOI18N
        JMIlocales.setText("Locales");
        JMmenu1.add(JMIlocales);

        JMIjugadores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_J, java.awt.event.InputEvent.CTRL_MASK));
        JMIjugadores.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/apps/kuser.png"))); // NOI18N
        JMIjugadores.setText("Jugadores");
        JMmenu1.add(JMIjugadores);

        JMIclubs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.ALT_MASK));
        JMIclubs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/filesystems/services.png"))); // NOI18N
        JMIclubs.setText("Clubs");
        JMmenu1.add(JMIclubs);

        JMIarbitros.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        JMIarbitros.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/apps/edu_languages.png"))); // NOI18N
        JMIarbitros.setText("Arbitros");
        JMmenu1.add(JMIarbitros);

        JMIequipos.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        JMIequipos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/actions/viewmag1.png"))); // NOI18N
        JMIequipos.setText("Equipos");
        JMmenu1.add(JMIequipos);

        JMIacta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK));
        JMIacta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/apps/kate.png"))); // NOI18N
        JMIacta.setText("Acta");
        JMmenu1.add(JMIacta);

        JMIRepresentantesClub.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.ALT_MASK));
        JMIRepresentantesClub.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/apps/personal.png"))); // NOI18N
        JMIRepresentantesClub.setText("Representantes Club");
        JMmenu1.add(JMIRepresentantesClub);

        jMenuBar1.add(JMmenu1);

        JMmenu2.setText("Tablas");
        JMmenu2.setActionCommand("Calendario");

        JMIranking.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK));
        JMIranking.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/apps/korganizer.png"))); // NOI18N
        JMIranking.setText("Ranking");
        JMmenu2.add(JMIranking);

        JMIclasequipos.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
        JMIclasequipos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/actions/view_text.png"))); // NOI18N
        JMIclasequipos.setText("Clasificación equipos");
        JMIclasequipos.setActionCommand("Clasequipos");
        JMmenu2.add(JMIclasequipos);

        JMIcalendario.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        JMIcalendario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/apps/date.png"))); // NOI18N
        JMIcalendario.setText("Calendario eventos");
        JMIcalendario.setActionCommand("Calendario");
        JMmenu2.add(JMIcalendario);

        jMenuBar1.add(JMmenu2);

        JMopciones.setText("Opciones");

        JMIlog.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.ALT_MASK));
        JMIlog.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/filesystems/file_broken.png"))); // NOI18N
        JMIlog.setText("Ver log");
        JMIlog.setActionCommand("Log");
        JMopciones.add(JMIlog);

        JMIacercaDe.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        JMIacercaDe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/apps/package_toys.png"))); // NOI18N
        JMIacercaDe.setText("Acerca De");
        JMopciones.add(JMIacercaDe);

        JMIconfig.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK));
        JMIconfig.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/apps/kcontrol.png"))); // NOI18N
        JMIconfig.setText("Configuración");
        JMIconfig.setActionCommand("Config");
        JMopciones.add(JMIconfig);
        JMopciones.add(jSeparator1);

        JMIsalir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        JMIsalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/16x16/actions/fileclose.png"))); // NOI18N
        JMIsalir.setText("Salir");
        JMopciones.add(JMIsalir);

        jMenuBar1.add(JMopciones);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JBarbitros;
    private javax.swing.JButton JBcalendario;
    private javax.swing.JButton JBclubs;
    private javax.swing.JButton JBjugadores;
    private javax.swing.JButton JBlocales;
    private javax.swing.JButton JBranking;
    private javax.swing.JDesktopPane JDPescritorio;
    private javax.swing.JLabel JLestado;
    private javax.swing.JMenuItem JMIRepresentantesClub;
    private javax.swing.JMenuItem JMIacercaDe;
    private javax.swing.JMenuItem JMIacta;
    private javax.swing.JMenuItem JMIarbitros;
    private javax.swing.JMenuItem JMIcalendario;
    private javax.swing.JMenuItem JMIclasequipos;
    private javax.swing.JMenuItem JMIclubs;
    private javax.swing.JMenuItem JMIconfig;
    private javax.swing.JMenuItem JMIequipos;
    private javax.swing.JMenuItem JMIjugadores;
    private javax.swing.JMenuItem JMIlocales;
    private javax.swing.JMenuItem JMIlog;
    private javax.swing.JMenuItem JMIranking;
    private javax.swing.JMenuItem JMIsalir;
    private javax.swing.JMenu JMmenu1;
    private javax.swing.JMenu JMmenu2;
    private javax.swing.JMenu JMopciones;
    private javax.swing.JProgressBar JPBcargando;
    private javax.swing.JPanel JPcargando;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the JDPescritorio
     */
    public javax.swing.JDesktopPane getJDPescritorio() {
        return JDPescritorio;
    }

    /**
     * @return the JPBcargando
     */
    public javax.swing.JProgressBar getJPBcargando() {
        return JPBcargando;
    }

    /**
     *
     * @return the JButton
     */
    public JButton getSalir() {
        return salir;
    }

    /**
     *
     * @return the JButton
     */
    public JButton getMinimizar() {
        return minimizar;
    }

    public void ponerFullScreen(){
//        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
//        GraphicsDevice gd = ge.getDefaultScreenDevice();
//        if (!gd.isFullScreenSupported()) {
//            JOptionPane.showMessageDialog(this, "Su tarjeta de grafica no dispone de soporte de Full-Screen.");
//
            this.setExtendedState(JFrame.MAXIMIZED_BOTH);
            this.setVisible(true);
//        }
//        try {
//            gd.setFullScreenWindow(this);
//        } catch (Throwable ex) {
//            Errors.creaError("No se puede poner la aplicación en FullScreen", ex.getStackTrace());
//        }
    }


}
